package pl.polidea.imf.blackberry.service.statemachine;

import pl.polidea.imf.blackberry.util.ClassHelper;

public abstract class State {
		
	final int subState;
	final Object param;
	
	public State(int subState){
		this(subState, null);
	}
	
	
	public State(int subState, Object param) {
		this.subState = subState;
		this.param = param;
	}
	
	public abstract State doWork();
		
	
	
	public int getSubState() {
		return subState;
	}
	
	public Object getParam() {
		return param;
	}
	
	public String toString() {
		String result;
		result = "Subclass: " + ClassHelper.trimClassName(getClass().getName()) + " Substate: " + getSubState();
		return result;
	}
	
	public boolean equals(Object obj) {
		if(!(obj instanceof State)){
			return false;
		}
		State o = (State)obj;
		
		if(o.subState==this.subState && o.param == this.param){
			return true;
		}
		
		return false;
		
	}
	
	
	
	
	
}
